package com.gpframework.module.base.domain.req;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.gpframework.common.utils.StringUtils;
import com.gpframework.module.base.domain.BaseDeviceInfo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;
import org.springframework.web.multipart.MultipartFile;

import javax.validation.constraints.NotBlank;
import java.io.File;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Set;

/**
 * @ClassName BaseDeviceInfoReq
 * @Author gpframework
 * @Date 2022-04-06
 * @Version 1.0.0
 * @Description 列表查询信息体
 */
@Data
@ToString
@EqualsAndHashCode
@NoArgsConstructor
@Accessors(chain = true)
public class BaseDeviceInfoNoPageReq {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("品牌id")
    private Long brandId;
    @ApiModelProperty("店铺id")
    private Long storeId;
    @ApiModelProperty("ID")
    private Long deviceInfoId;
    @ApiModelProperty("厂家id")
    private String companyId;
    @ApiModelProperty("厂家名称")
    private String companyName;
    @ApiModelProperty("设备分类")
    private String deviceClassification;
    @ApiModelProperty("设备类型")
    private String deviceType;
    @ApiModelProperty("设备序列号。门店下必定唯一")
    private String deviceSn;
    @ApiModelProperty("设备名称")
    private String deviceName;
    @ApiModelProperty("设备型号")
    private String deviceModel;
    @ApiModelProperty("款式")
    private String style;
    @ApiModelProperty("尺寸")
    private String size;
    @ApiModelProperty("设备号")
    private String deviceCode;
    @ApiModelProperty("颜色")
    private String color;
    @ApiModelProperty("单位")
    private String unit;
    @ApiModelProperty("特点")
    private String characteristic;
    @ApiModelProperty("产品特点介绍")
    private String characteristicDetail;
    @ApiModelProperty("进货价")
    private BigDecimal buyPrice;
    @ApiModelProperty("销售价")
    private BigDecimal salePrice;
    @ApiModelProperty("是否是我们自己的产品")
    private String isWe;
    @ApiModelProperty("排序")
    private Long sort;
    @ApiModelProperty("备注")
    private String remarks;
    @ApiModelProperty("创建者")
    private String createBy;
    @ApiModelProperty("创建时间")
    private Date createTime;
    @ApiModelProperty("更新者")
    private String updateBy;
    @ApiModelProperty("更新时间")
    private Date updateTime;
    @ApiModelProperty("删除标记;0未删除。1已删除。")
    private Long delStatus;
    @ApiModelProperty("涉及的数据JSON;建议是JSON字符串")
    private String dataJson;


    /**
     * 闸机设备号
     */
    @ApiModelProperty("闸机设备号")
    private String gateDeviceCode;

    /**
     * 状态：正常
     */
    @ApiModelProperty("状态：正常")
    private String status;

    /**
     * 闸机等级
     */
    @ApiModelProperty("闸机等级")
    private String gateLevel;

    /**
     * 继电器端口
     */
    @ApiModelProperty("继电器端口")
    private String relayPort;

    /**
     * 控制闸机
     */
    @ApiModelProperty("控制闸机")
    private String controlGate;

    /**
     * 使用场景
     */
    @ApiModelProperty("使用场景")
    private String usageScenarios;

    /**
     * 门店id
     */
    @ApiModelProperty("门店id")
    private Set<Long> storeIdSet;

    /**
     * 授权组id（场地）列表
     */
    private Set<String> personsetGuidSet;

    /**
     * 用户id
     */
    private Long userId;

    /**
     * 用户名称
     */
    private String userName;
    /**
     * 用户idList
     */
    private List<String> userIdList;

//    /**
//     * 同步日志
//     */
//    private List<BrandStoreUserFaceRelaVoReception> brandStoreUserFaceRelaVoList;

    /**
     * 手机号
     */
    @ApiModelProperty("手机号")
    private String mobile;

    /**
     * 人脸
     */
    @ApiModelProperty("人脸")
    private String faceImage;
    @ApiModelProperty("会员入场凭证id")
    private Long userCardRecordId;
    @ApiModelProperty("入场凭证类型： 10会员卡 20课程")
    private String proofType;
    @ApiModelProperty("凭证类型 1期限卡 2次卡 3课程")
    private String voucherType;
    @NotBlank(message = "请输入类型 1头像 2照片墙 3声音文件")
    @ApiModelProperty(value = "类型 1头像 2照片墙 3声音文件 5URL",required = true)
    private String fileType;
    @ApiModelProperty(value = "文件",required = true)
    private MultipartFile file;
    @ApiModelProperty(value = "文件",required = true)
    private File fileTest;
    @ApiModelProperty(value = "智慧前台人脸用户ID",required = true)
    private String faceSetid;
    @ApiModelProperty(value = "智慧前台人脸用户缓存二维码",required = true)
    private String userCode;
    @ApiModelProperty(value = "智慧前台人脸用户卡号",required = true)
    private String userCard;
    @ApiModelProperty(value = "短信验证码",required = true)
    private String code;
    @ApiModelProperty(value = "投诉建议内容",required = true)
    private String content;
    @ApiModelProperty("预约id")
    private Long subscribeCourseId;
    @ApiModelProperty("版本号")
    private String version;
    @ApiModelProperty("机器指纹")
    private String fingerprint;
    @ApiModelProperty("是否查询缓存")
    private String isCache;
//    @ApiModelProperty("人脸")
//    private UserFace userFace;

    /**
     * @Description 生成查询wrapper
     * @Author greatplan@qq.com
     * @Date 2020-11-04 16:04
     * @Param [lqw]
     * @Param [isVO] 是否vo查询体，true的话走的是mapper.xml里面的查询语句，不过查询语法还是mybatis-plus，主要用于某些关联查询出一些非数据表字段
     * @Return void
     */
    public void generatorQuery(QueryWrapper<BaseDeviceInfo> lqw, boolean isVo) {
        String alias = "";
        if (isVo) {
            alias = "gp.";
            lqw.eq(alias + "del_status", 0);
        }
        if (this.getDeviceInfoId() != null) {
            lqw.eq(alias + "device_info_id", this.getDeviceInfoId());
        }
        if (StringUtils.isNotBlank(this.getCompanyId())) {
            lqw.eq(alias + "company_id", this.getCompanyId());
        }
        if (StringUtils.isNotBlank(this.getCompanyName())) {
            lqw.like(alias + "company_name", this.getCompanyName());
        }
        if (StringUtils.isNotBlank(this.getDeviceClassification())) {
            lqw.eq(alias + "device_classification", this.getDeviceClassification());
        }
        if (StringUtils.isNotBlank(this.getDeviceType())) {
            lqw.eq(alias + "device_type", this.getDeviceType());
        }
        if (StringUtils.isNotBlank(this.getDeviceName())) {
            lqw.like(alias + "device_name", this.getDeviceName());
        }
        if (StringUtils.isNotBlank(this.getDeviceModel())) {
            lqw.eq(alias + "device_model", this.getDeviceModel());
        }
        if (StringUtils.isNotBlank(this.getStyle())) {
            lqw.eq(alias + "style", this.getStyle());
        }
        if (StringUtils.isNotBlank(this.getSize())) {
            lqw.eq(alias + "size", this.getSize());
        }
        if (StringUtils.isNotBlank(this.getDeviceCode())) {
            lqw.eq(alias + "device_code", this.getDeviceCode());
        }
        if (StringUtils.isNotBlank(this.getColor())) {
            lqw.eq(alias + "color", this.getColor());
        }
        if (StringUtils.isNotBlank(this.getUnit())) {
            lqw.eq(alias + "unit", this.getUnit());
        }
        if (StringUtils.isNotBlank(this.getCharacteristic())) {
            lqw.eq(alias + "characteristic", this.getCharacteristic());
        }
        if (StringUtils.isNotBlank(this.getCharacteristicDetail())) {
            lqw.eq(alias + "characteristic_detail", this.getCharacteristicDetail());
        }
        if (this.getBuyPrice() != null) {
            lqw.eq(alias + "buy_price", this.getBuyPrice());
        }
        if (this.getSalePrice() != null) {
            lqw.eq(alias + "sale_price", this.getSalePrice());
        }
        if (StringUtils.isNotBlank(this.getIsWe())) {
            lqw.eq(alias + "is_we", this.getIsWe());
        }
        if (this.getSort() != null) {
            lqw.eq(alias + "sort", this.getSort());
        }
        if (StringUtils.isNotBlank(this.getRemarks())) {
            lqw.eq(alias + "remarks", this.getRemarks());
        }
        if (StringUtils.isNotBlank(this.getCreateBy())) {
            lqw.eq(alias + "create_by", this.getCreateBy());
        }
        if (this.getCreateTime() != null) {
            lqw.eq(alias + "create_time", this.getCreateTime());
        }
        if (StringUtils.isNotBlank(this.getUpdateBy())) {
            lqw.eq(alias + "update_by", this.getUpdateBy());
        }
        if (this.getUpdateTime() != null) {
            lqw.eq(alias + "update_time", this.getUpdateTime());
        }
        if (this.getDelStatus() != null) {
            lqw.eq(alias + "del_status", this.getDelStatus());
        }
        lqw.orderByDesc(alias + "update_time");
    }

    public QueryWrapper<BaseDeviceInfo> generatorQuery(BaseDeviceInfoNoPageReq req) {
        if (req == null) {
            req = new BaseDeviceInfoNoPageReq();
        }

        QueryWrapper<BaseDeviceInfo> result = new QueryWrapper<>();
        req.generatorQuery(result, true);
        return result;
    }
}
